<?php
require_once("../../../config.inc.php");
$isReloadable = false;
require_once("../../../app/_inc/include.php");
require_once("profileFunction.php");

$errMsg = "";
$description = sxREQUEST("description");
$note = sxREQUEST("note");
if(isset($_REQUEST["reqtype"]) && $_REQUEST["reqtype"] == "save"){
	$errMsg .= profileIns();	
}

//output HTML
$aOpz = array("tit2"=>_t("Nuovo profilo"), "isReloadable"=>false);
echo(headerHTML($aOpz));
?>
<script language="JavaScript" type="text/javascript" src="../../_jsc/ajax.js"></script>  
<script language="JavaScript" type="text/javascript">
	function objFrmSave(){
		var errMsg = "";
		var objFrm = document.getElementById("objFrm");
		var objMessArea =  document.getElementById("messArea");
		
		var obj =  document.getElementById("description");
		if(obj.value == ""){
			errMsg += "<?php echo _t("La description &egrave; obbligatoria");?>.<br>";
			obj.className = "inpt01";
			obj.focus();
		}else{
			obj.className = "inpt01";
		}
		if(errMsg == ""){
			objFrm.submit();
		}else{
			objMessArea.innerHTML = errMsg;
		}		
	}
</script>
  
<?php
echo(bodyHTML($aOpz));
echo("<table width=\"100%\" cellpadding=\"03\" cellspacing=\"0\">\n<tr>\n<td>\n");
//form inserimento dati
echo("<form name=\"objFrm\" id=\"objFrm\" action=\"profileIns.php\" method=\"POST\">");
echo("<input type=\"hidden\" name=\"xsn\" value=\"".XSN."\">");
echo("<input type=\"hidden\" name=\"reqtype\" id=\"reqtype\" value=\"save\">");
//output comandi
$aCmd = array("ins"=>array("pag"=>"javascript:objFrmSave()",
										"title"=>_t("Salva i dati del nuovo profilo"),
										"text"=>_t("salva"),
										"perm"=>"newuser"),
					"back"=>array("pag"=>$objUser->getHistory(-1,false),
										"title"=>$objUser->getHistoryText(-1),
										"text"=>$objUser->getHistoryText(-1))
					);
echo(commandsHTML($aCmd));	
echo("<table calss=\"tabl01\" width=\"100%\" cellpadding=\"3\" cellspacing=\"2\">\n");
echo("<tr>" .
			"<td class=\"titl01\" colspan=\"2\">"._t("Profili")."</td>" .
		"</tr>\n");
echo("<tr>" .
			"<td class=\"labl01\">"._t("description")."*</td>" .
			"<td class=\"text01\"><input class=\"inpt01\" type=\"text\" name=\"description\" id=\"description\" maxlength=\"128\" size=\"32\" value=\"".sxHE($description)."\"></td>" .
		"</tr>\n");
echo("<tr>" .
				"<td class=\"labl01\">"._t("note")."</td>" .
				"<td class=\"text01\"><textarea class=\"inpt01\" name=\"note\" id=\"note\" cols=\"50\" rows=\"8\">".sxHE($note)."</textarea></td>" .
			"</tr>\n");
echo("</table>");

echo(commandsHTML($aCmd));
echo("</form>");
echo("</td>\n</tr>\n</table>\n");
echo(footerHTML());
$objSDAO->close();
?>
